package com.azf.test.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/*
功能描述:
作者：14136
创造日期：2024/11/Data16
*/
@Data//
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {
    private static final Integer SUCCESS = 200;//成功
    private static final Integer AUTH_ERROR = 401;//权限不足
    private static final Integer SYSTEM_ERROR = 301;//跳转重定向到登录
    private static final Integer ERROR = 500;//服务器异常


    private Integer code;
    private String msg;
    private T data;

    public Result Success() {//无参，默认成功

        return new Result(SUCCESS, "success", null);
    }

    public Result Success(T data) {//有参，默认成功
        return new Result(SUCCESS, "success", data);
    }

    public Result error(String msg) {//有参，默认失败
        return new Result(ERROR, msg, null);
    }

    public Result error(Integer code, String msg) {//有参，自定义失败
        return new Result(code, msg, null);
    }

    public Result error() {//无参，默认失败
        return new Result(500, "系统错误，请联系管理员", null);
    }


}
